<template>
	<view class="personalCenter-view">
			<!-- jl 经理  cg 仓管  sj司机 -->
		<view :class="'personalCenter-header '+(identity==2||identity==3?'jl':identity==5?'cg':identity==4?'sj':'jl') ">
			<view class="top">
				<image class="black" @tap="black" src="/static/images/bzuo.png" mode=""></image>
			</view>
			
			
		</view>
		<view class="personalTop">
			<view class="header" v-if="identity==2||identity==3">
				<view class="comp-img" style="width: 140upx; height: 140upx;margin:0px auto;">
					<avatar class="img"
				        selWidth="200px" selHeight="400upx" @upload="myUpload" :avatarSrc="url?url:'/static/images/header.png'"
				        avatarStyle="width: 140upx; height: 140upx; border-radius: 100%; margin:0px auto;" >
				    </avatar>
				</view>
				<!-- <image src="" mode=""></image> -->
				<view class="identity">
					{{identity==2?'经理':'总经理'}}
				</view>
			</view>
			
			<view class="header"  v-if="identity==5">
				<view class="comp-img" style="width: 140upx; height: 140upx;margin:0px auto;">
					<avatar class="img"
							selWidth="200px" selHeight="400upx" @upload="myUpload" :avatarSrc="url?url:'/static/images/cgheader.png'"
							avatarStyle="width: 140upx; height: 140upx; border-radius: 100%;" >
					</avatar>
				</view>
				<view class="identity">
					仓管
				</view>
			</view>
			
			<view class="header" v-if="identity==4">
				<view class="comp-img" style="width: 140upx; height: 140upx;margin:0px auto;">
					<avatar class="img"
				        selWidth="200px" selHeight="400upx" @upload="myUpload" :avatarSrc="url?url:'/static/images/sjheader.png'"
				        avatarStyle="width: 140upx; height: 140upx; border-radius: 100%; margin:0px auto;" >
				    </avatar>
				</view>
				<view class="identity">
					司机
				</view>
			</view>
			
			<view class="center">
				<view class="cnetr-list">
					<view class="tit">姓名</view>
					<view class="con">{{userInfo.nickName}}</view>
				</view>
				<!-- 仓管没有编号 -->
				<view class="cnetr-list" v-if="identity!=5">
					<view class="tit">编号</view>
					<view class="con">{{userInfo.salesmanNo}}</view>
				</view>
				<view class="cnetr-list">
					<view class="tit">电话</view>
					<view class="con">{{userInfo.mobile}}</view>
				</view>
			</view>
		</view>	
		<!-- 这个版本不上线 -->
		<!-- <view class="qiandao-box" v-if="identity==2">
			
			<view class="qiandao-box-content">
					<view class="qiandao-box-item" @click="skipToSignCenter()">
						<view class="img-box">
							<image src="/static/images/qdzx.png"></image>
						</view>
						<view class="text">签到中心</view>
					</view>
					<view class="qiandao-box-item" @click="skipToSignCalc()">
						<view class="img-box">
							<image src="/static/images/qdtj.png"></image>
						</view>
						<view class="text">签到统计</view>
					</view>
			</view>
		
		</view> -->
		<view class="list-box">
			<view class="list">
				<image class="bbh" src="/static/images/bbh.png" mode=""></image>
				<view class="list-left">
					版本号
				</view>
				<view class="list-right">
					V{{version}}
				</view>
			</view>
			<view class="list" @tap="yhxy">
				<image class="yhxy" src="/static/images/yhxy.png" mode=""></image>
				<view class="list-left">
					用户协议
				</view>
				<view class="list-right">
					<image class="you" src="/static/images/you.png" mode=""></image>
				</view>
			</view>
			<view class="list"  @tap="ysxy">
				<image class="ysxy" src="/static/images/ysxy.png" mode=""></image>
				<view class="list-left">
					隐私协议
				</view>
				<view class="list-right">
					<image class="you" src="/static/images/you.png" mode=""></image>
				</view>
			</view>
		</view>
		
		
		
		<view class="btn" @tap="out">
			退出登录
		</view>
	</view>
</template>

<script>
	import avatar from "../../components/yq-avatar/yq-avatar.vue";
	const util = require("../../utils/util.js");
	//获取应用实例
	const api = require("../../config/api.js");
	export default {
		data() {
			return {
				identity:'',
				userInfo:{},
				url:'',
				version:''
			}
		},
		components: {
		            avatar
		},
		onShow() {
			uni.setStorageSync('isGetShopInforStorage',false);
		},
		onLoad(){
			this.identity = uni.getStorageSync('identity')
			this.version = plus.runtime.version;
			console.log(this.version)
			// 取消订单
			util.request(api.businessUserInfo, {}, 'POST').then(res => {
				console.log(res)
				this.userInfo = res.data
			})
		},
		methods: {
			black(){
				uni.navigateBack()
			},
			out(){
				util.request(api.userOut, {}, 'POST').then(res => {
						
						
						// 存入token
						uni.setStorageSync('token','')
						// 存入个人数据
						uni.setStorageSync('userInfo','');
						// 是否登录
						uni.setStorageSync('isLogin','');
						// 存入人员id（0:B端用户 1:C端用户 2:业务员 3:经理 4:司机 5:仓管）
						uni.setStorageSync('identity','');
						
						uni.reLaunch({
							url:'/pages/login/login'
						})
			
				})
				
			},
			myUpload(rsp) {
				this.url = rsp.path; //更新头像方式一
				//rsp.avatar.imgSrc = rsp.path; //更新头像方式二
				
				util.request(api.updateBusinessUser, {
					avatarUrl:rsp.path
				}, 'POST').then(res => {
						
						if(res.error==0){
							uni.showToast({
								title:'修改成功'
							})
						}
					console.log(res)
							
				})
			},
			yhxy(){
				console.log(123456)
				uni.navigateTo({
					url:'/pages/serviceAgreement/serviceAgreement'
				})
			},
			ysxy(){
				uni.navigateTo({
					url:'/pages/privacyPolicy/privacyPolicy'
				})
			},
			skipToSignCenter(){
				uni.navigateTo({
					url:'/pages/signinCenter/signinCenter'
				})
			},
			skipToSignCalc(){
				uni.navigateTo({
					url:'/pages/signinCalc/signinCalc'
				})
			},
			
			
		}
	}
</script>

<style>
	@import url("./personalCenter.css");
</style>
